#include "core\GameState.h"

GameState::GameState(StateManager* stateManager) : m_stateManager(stateManager)
{
}

void GameState::changeState(GameState* state)
{
  m_stateManager->changeState(state);
}


StateManager::StateManager() : m_activeState(NULL)
{
}

StateManager::~StateManager()
{
  if(m_activeState != NULL) m_activeState->exitState();
}

void StateManager::changeState(GameState* state)
{
  if(m_activeState != NULL) m_activeState->exitState();
  m_activeState = state;
  m_activeState->enterState();
}

GameState* StateManager::getActiveState()
{
  return m_activeState;
}

void StateManager::draw()
{
  if(m_activeState != NULL) m_activeState->draw();
}

APP_MSG StateManager::update(DWORD milliseconds, Keys* keys, Mouse* mouse)
{
  APP_MSG msg = MSG_NONE;
  if(m_activeState != NULL) msg = m_activeState->update(milliseconds, keys, mouse);
  return msg;
}